package rolesystem.roles.auction;

import rolesystem.core.RoleAction;
import rolesystem.roles.KnownEvent;

/**
 * This role is the auctioneer of an auction.
 * Keywords: auction, auctioneer.
 */
public abstract class Auctioneer
{
	/**
	 * Role identifier.
	 */
	public static final String ROLE_ID="auction.Auctioneer";


	/**
	 * A seller requests to put a good on sale.
	 * Sender role: Seller
	 */
	public static final KnownEvent KE_reqSale=new KnownEvent("reqSale", Seller.ROLE_ID);

	/**
	 * A seller puts a good on sale.
	 * Sender role: Seller
	 * Content: Characteristics of the sale, i.e. reserve price, good on sale and its description.
	 */
	public static final KnownEvent KE_putOnSale=new KnownEvent("putOnSale", Seller.ROLE_ID, Sale.class);

	/**
	 * A bidder asks the kind of the auction (English, Dutch...).
	 * Sender role: Bidder
	 */
	public static final KnownEvent KE_askKind=new KnownEvent("askKind", Bidder.ROLE_ID);

	/**
	 * A bidder asks the description of the good on sale.
	 * Sender role: Bidder
	 */
	public static final KnownEvent KE_askGood=new KnownEvent("askGood", Bidder.ROLE_ID);

	/**
	 * A bidder asks the current situation of the auction.
	 * Sender role: Bidder
	 */
	public static final KnownEvent KE_askSituation=new KnownEvent("askSituation", Bidder.ROLE_ID);

	/**
	 * A bidder makes a bid.
	 * Sender role: Bidder
	 * Content: Bid.
	 */
	public static final KnownEvent KE_bid=new KnownEvent("bid", Bidder.ROLE_ID, Price.class);

	/**
	 * A bidder pays.
	 * Sender role: Bidder
	 * Content: Payment.
	 */
	public static final KnownEvent KE_pay=new KnownEvent("pay", Bidder.ROLE_ID, Money.class);


	/**
	 * Notifies to a seller that its sale has been accepted.
	 * @param addressee Seller
	 */
	public static RoleAction saleAccepted(int addressee)
	{
		return new RoleAction("saleAccepted", addressee);
	}

	/**
	 * Notifies to a seller that its sale has been refused.
	 * @param addressee Seller
	 */
	public static RoleAction saleRefused(int addressee)
	{
		return new RoleAction("saleRefused", addressee);
	}

	/**
	 * Notifies to a seller that its good is unsold.
	 * @param addressee Seller
	 */
	public static RoleAction unsold(int addressee)
	{
		return new RoleAction("unsold", addressee);
	}

	/**
	 * Pays.
	 * @param addressee Seller
	 * @param content Payment.
	 */
	public static RoleAction pay(int addressee, Money content)
	{
		return new RoleAction("pay", addressee, content);
	}

	/**
	 * Notifies the kind of the auction.
	 * @param addressee Bidder
	 * @param content Kind of the auction (English, Dutch...).
	 */
	public static RoleAction notifyKind(int addressee, String content)
	{
		return new RoleAction("notifyKind", addressee, content);
	}

	/**
	 * Notifies the good on sale.
	 * @param addressee Bidder
	 * @param content Description of the good on sale.
	 */
	public static RoleAction notifyGood(int addressee, String content)
	{
		return new RoleAction("notifyGood", addressee, content);
	}

	/**
	 * Notifies the current situation of the auction.
	 * @param addressee Bidder
	 * @param content Situation of the auction, i.e. proposed price, winning bidder and countdown state.
	 */
	public static RoleAction notifySituation(int addressee, Situation content)
	{
		return new RoleAction("notifySituation", addressee, content);
	}

	/**
	 * Notifies that the auction is over.
	 * @param addressee Bidder
	 */
	public static RoleAction auctionOver(int addressee)
	{
		return new RoleAction("auctionOver", addressee);
	}

	/**
	 * Notifies to a bidder that it has won the auction and thus it must pay.
	 * @param addressee Bidder
	 * @param content Price that must be paid.
	 */
	public static RoleAction youWon(int addressee, Price content)
	{
		return new RoleAction("youWon", addressee, content);
	}

	/**
	 * Gives a good.
	 * @param addressee Bidder
	 * @param content Good.
	 */
	public static RoleAction giveGood(int addressee, java.io.Serializable content)
	{
		return new RoleAction("giveGood", addressee, content);
	}
}
